﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ITAP.ContourBuilder.Components;
using ITAP.Core.Modelling;

namespace ITAP.ContourBuilder.Operations
{
    public class OperationAlignConnectorsHorizontal : OperationWithSelectedConnectors
    {
        public override string ToString()
        {
            return "Выровнять соединители по горизонтали";
        }

        public override void Execute()
        {
            base.Execute();
            if (connectors.Count < 2)
            {
                this.Cancel();
                return;
            }

            ContourConnector mainConnector = connectors[0];
            for (int i = 1; i < connectors.Count; i++)
                connectors[i].MoveTo(new ModelPoint(connectors[i].Position.X, mainConnector.Position.Y));
            this.Control.UpdateModel();
            this.Exit();
        }

        public override bool CanUndo
        {
            get
            {
                return true;
            }
        }
    }
}
